if [ $# -lt 1 ]; then
    echo "use me as: restore.sh backupname"
    echo "for example: ./restore.sh 2023-Jun-14-1859.caidx"
    exit 1
fi

echo "restoring $1..."
pushd `dirname $0`
cd ..
sudo docker build --tag backupper ./docker/backupper
./scripts/backup-man.sh
sudo docker run -t --volume $(pwd):/data backupper casync extract --store=/data/backups/casync-store.castr /data/backups/$1 /data/volumes
sudo chmod -R 0777 ./volumes
popd